<template>
  <!-- 标签显示 -->
  <div>
    <div class="tag" @click="openTags">
      <div class="tag-item" v-for="(item, index) in tags" :key="item+index">
        <van-icon custom-class="tag-icon" name="passed" color="red" size="24rpx"/>
        <span class="tag-title">{{item}}</span>
      </div>

      <div class="tags-move">
        <img src="/static/images/arrow-right-s-line.png">
      </div>
    </div>

    <!-- 弹出层tags -->
    <wux-popup position="bottom"
      :visible="showTag"
      @close="closeTags"
      closable
    >
      <wux-cell-group title="服务说明">
        <div class="content">
          <div class="content-list">
            <div class="title">全场包邮</div>
            <div class="describe">所有商品均无条件包邮</div>
          </div>

          <div class="content-list">
            <div class="title">7天退换</div>
            <div class="describe">满足相应条件时，消费者可申请7天无理由退换货</div>
          </div>
          <div class="content-list">
            <div class="title">24小时发货</div>
            <div class="describe">下单成功后，商品24小时内发货</div>
          </div>
          <div class="content-list">
            <div class="title">上门安装</div>
            <div class="describe">下单成功后，本公司立刻安排专业师傅上门安装服务</div>
          </div>
        </div>
      </wux-cell-group>
    </wux-popup>
  </div>
</template>

<script scope>
export default {
  props: ['tags'], // 接收外部传入的数据
  data () {
    return {
      showTag: false // tags弹出蒙层控制
    }
  },
  // 自定义函数
  methods: {
    // 打开弹出层
    openTags () {
      this.showTag = true
    },
    // 关闭弹出层(弹出点击遮罩层事件也用它)
    closeTags () {
      this.showTag = false
    }
  }
}
</script>

<style scope>
/* tag标签 */
.tag {
  position: relative;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  word-break: break-all;
  /* margin: 10rpx 0; */
  height: 62rpx;
  line-height: 56rpx;
}
.tag-item {
  display: inline-block;
  margin-right: 10rpx;
}
.tag-icon {
  bottom: 0;
  vertical-align: middle;
}
.tag-title {
  font-size: 24rpx;
}
.tags-move {
  position: absolute;
  top: 8rpx;
  right: -15rpx;
  width: 56rpx;
  height: 56rpx;
}
.tags-move img {
  width: 36rpx;
  height: 36rpx;
}
/* 弹出层样式 */
.content {
  padding-bottom: 30px;
}
.content .content-list {
  padding: 12px 14px 0 14px;
  text-align: left;
  box-sizing: border-box;
}
.content .content-list .title {
  height: 40rpx;
  line-height: 40rpx;
  font-size: 34rpx;
  color: black;
}
.content .content-list .describe {
  line-height: 60rpx;
}
</style>
